package com.qf.hospital.serializer;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

import java.io.IOException;

/**
 * @author zjw
 * @description  处理身份证号的序列化工具
 * @date 2021/10/20 10:24
 */
public class HiddenCardIdInformationJsonSerializer extends JsonSerializer<String> {

    @Override
    public void serialize(String value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
        String cardId = value.substring(0,4) + "****" + value.substring(value.length() - 4);
        gen.writeString(cardId);
    }



}
